home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGBLER
/
WASM211B.LZH
/
BOOT.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-03-06
|
4KB
|
146 lines
Title 'Wolfware Sample Program', 'Computer Reboot'
;=============================================================================
; Computer Reboot
;
; Carry out a cold (with memory check) or warm (without memory check) boot.
; A cold boot is just as if the computer has been turned off and then back
; on. The memory will be checked for errors. A warm boot is the same as
; pressing CTRL-ALT-DEL. The memory is not checked for errors. This program
; might be useful in a batch file that changes the system parameters and then
; must restart the computer.
;
; Examples:
;
; BOOT warm
; this will initiate a warm boot
;
; BOOT cold
; this will initiate a cold boot
;
; WARNING: All data in the computer will be lost, including that which is in
; memory resident programs or RAM disks. Please save all data before
; executing this program.
Mov Si, Command_Line ;get command line location
Lodsb ;load length and point to first byte
Or Al, Al ;check if no parameter
Jz Main2
Mov Cl, Al
Sub Ch, Ch ;CX has byte count
;--- skip preceding spaces in command line
Main1
Cmp Byte [Si], ' ' ;check if space
Jne Main3
Inc Si ;next byte
Loop Main1 ;loop back if more
;--- illegal parameter
Main2
Mov Dx, Offset Error_Message ;message
Mov Ah, 9 ;DOS print function
Int 21h ;execute
Mov Ax, 4cffh ;exit with error code 255
Int 21h ;execute
;--- found start of parameter
Main3
Cmp Cx, 4 ;check if too few bytes
Jb Main2 ;jump if so, error
Je Main4 ;jump if same length
Mov Cx, 4 ;set to max length, ignore other characters
Main4
Push Cx
Push Si
;--- check if cold parameter
Mov Ax, Cold_Boot ;cold boot flag
Mov Di, Offset Cold ;check if cold message
Call Cmp_Str ;compare strings
Jz Main5 ;jump if equal, cold boot
;--- not cold, check if warm parameter
Pop Si
Pop Cx
Mov Ax, Warm_Boot ;warm boot flag
Mov Di, Offset Warm ;check if warm message
Call Cmp_Str ;compare strings
Jnz Main2 ;jump if not equal, error
;--- continue with reboot, reset flag in AX
Main5
Sub Bx, Bx
Mov Ds, Bx ;segment zero
Mov Word [Reset_Flag], Ax ;set reset flag
;--- the following code initializes the registers and is probably not needed,
;--- the "Intel iAPX 86/88, 186/188 User's Manual Programmer's Reference" says
;--- this is done by a hardware reset (through the RESET lines) and it does
;--- seem to work okay without it
Sub Ax, Ax ;zero to AX
Push Ax
Popf ;clear all flags
Mov Ds, Ax
Mov Es, Ax
Mov Ss, Ax ;clear segment regs
;--- initiate reboot, jump to first instruction
Jmp 0, 0ffffh ;branch to FFFF:0000
;================================================
; Compare two (text) strings.
; In: DI= string one; SI= string two, which is
; converted to lower-case; CX= bytes to check.
; Out: ZF= set if strings are equal.
Cmp_Str Proc Near
Cmpstr1
Or Byte [Si], 'a'-'A' ;make lower-case
Cmpsb ;compare bytes
Jne Cmpstr2 ;jump if no match
Loop Cmpstr1 ;loop back if more to check
Cmpstr2
Ret
Endp ;Cmp_Str
;================================================
; Program data.
;--- parameter data
Command_Line Equ 80h ;offset of command line
Cold Db 'cold' ;cold parameter
Warm Db 'warm' ;warm parameter
;--- reset flag data; note that since the flag's cleared value (cold boot) is
;--- is not defined in the BIOS data area, I used an abitrary number that is
;--- not equal to the set value; if the operating system or BIOS uses this
;--- variable for other purposes, doing a cold boot might cause unexpected
;--- results or a system crash
Reset_Flag Equ 0472h ;memory offset, at segment 0
Cold_Boot Equ 0000h ;value to set if cold boot, <> WARM_BOOT
Warm_Boot Equ 1234h ;value to set if warm boot
;--- error message
Error_Message Label Byte
Db 'BOOT: usage is BOOT WARM or BOOT COLD',13,10,'$'